﻿Public Class AnimationScreenflash
    Inherits ObjektAnimation
    Const FrameMax As Integer = 51
    Public Sub New(ByVal Musikspielen As Boolean)
        MyBase.New(Musikspielen, ObjektSpielfeld.TopLayer)

        'Wir fuegen die Handler hinzu
    End Sub
    Public Overrides Function Malen(ByVal intColor As System.Drawing.Color, Optional ByVal Zoomfaktor As Single = 1.0, Optional ByVal Feldbreite As Integer = -1) As Boolean
        If DataSettings.draw3D Or DataSettings._2D_3D_Malen Then
            Grafikengine.Sprite.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend)
        End If
        If Frame <= 25 Then
            Grafikengine.fillRect(New Rectangle(0, 0, DataSettings.BildschirmBreite, DataSettings.BildschirmHoehe), Color.FromArgb(Frame * 10, 255, 255, 255))
        ElseIf Frame > 25 And Frame <= 26 Then
            Grafikengine.fillRect(New Rectangle(0, 0, DataSettings.BildschirmBreite, DataSettings.BildschirmHoehe), Color.FromArgb(255, 255, 255, 255))
        Else

            Dim Alpha As Integer = 250 - (Frame - 26) * 10
            If Alpha < 0 Then Alpha = 0
            Grafikengine.fillRect(New Rectangle(0, 0, DataSettings.BildschirmBreite, DataSettings.BildschirmHoehe), Color.FromArgb(Alpha, 255, 255, 255))
        End If
        If DataSettings.draw3D Or DataSettings._2D_3D_Malen Then
            Grafikengine.Sprite.End()
        End If
        If FrameMax >= Frame Then
            Frame += 1
            Return True
        Else
            Return False
        End If
    End Function
    Public Overrides Sub MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Select Case e.Button
            Case MouseButtons.Right
                Frame += FrameMax
        End Select
    End Sub
    Public Overrides Sub KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        Select Case e.KeyCode
            Case DataSettings.Bestaetigen
                Frame += FrameMax
            Case DataSettings.Abrechen
                Frame += FrameMax
        End Select
    End Sub
    Public Overrides Sub RemoveHandles()
        MyBase.RemoveHandles()
    End Sub
End Class
